<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        window.onload = function () {
            var oBtn = document.getElementById("btn");

            oBtn.onclick = function () {
                // var href = window.location.href;
                // console.log(href);

                // window.location.href = "http://www.baidu.com";

                // 打开页面 默认是开启新标签页 _blank
                window.open("http://www.baidu.com","_self");
            }
        }
    </script>

</head>

<body>

    <div id="btn">点我跳转</div>

</body>

</html>